package com.bankcomm.iccard;

import java.util.HashMap;

import com.bankcomm.R;
import com.bankcomm.common.ConfigManager;
import com.bankcomm.common.LPMid;
import com.bankcomm.ui.views.BCMHomeView;
import com.bankcomm.ui.views.LPBottomBar;
import com.bankcomm.util.LPUtils;

import android.content.BroadcastReceiver;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ICCard_Balance_Query_Activity extends BaseActivity implements OnClickListener {
	BroadcastReceiver audioDeviceReceiver;
	TextView tvICCard_ID, tvAccountBalance, tvCard_Balance,ic_balance_query_prompt;
	Button btnReturn, btnHome;
	LinearLayout ic_balancequery_prompt_pic ;
	private LPBottomBar bottomBar;
	private RelativeLayout topLayout;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.iccard_balance_query);
		bottomBar=(LPBottomBar)findViewById(R.id.bottom_bar);
		topLayout=(RelativeLayout)findViewById(R.id.titleLayout);
		
		tvICCard_ID = (TextView) findViewById(R.id.iccardid);
		tvAccountBalance = (TextView) findViewById(R.id.accountbalance);
		tvCard_Balance = (TextView) findViewById(R.id.cardbalance);
		ic_balance_query_prompt =(TextView) findViewById(R.id.ic_balance_query_prompt);
		
		ic_balancequery_prompt_pic =(LinearLayout)findViewById(R.id.ic_balancequery_prompt_pic);
		
		btnReturn = (Button) findViewById(R.id.backtitle);
		btnHome = (Button) findViewById(R.id.hometitle);
		
		((LPBottomBar) findViewById(R.id.bottom_bar)).setSelectTab(2);
		setLayoutHeight();
		btnReturn.setOnClickListener(this);
		btnHome.setOnClickListener(this);
	}
	
	private void setLayoutHeight() {
		LPUtils.scaledTHeightRel(topLayout);
		LPUtils.setTitleButtonWH(btnReturn);
		LPUtils.setTitleButtonWH(btnHome);
//		LPUtils.scaledTHeight(bottomBar);
		
	}

	/**
	 * 6222620110003251817|000000010000|ER TONG KA YI|00|310100199012161688 pan/金额/姓名/卡类型/kahao
	 **/
	public void handlerAudioMap(String[] cardInfoArray) {
		LPMid.getInstance().audioCardInfo = new HashMap<String, String>();

		LPMid.getInstance().audioCardInfo.put("PAN", cardInfoArray[0]);
		LPMid.getInstance().audioCardInfo.put("Balance", cardInfoArray[1]);
		LPMid.getInstance().audioCardInfo.put("UserName", cardInfoArray[2]);
		LPMid.getInstance().audioCardInfo.put("CertType", cardInfoArray[3]);
		LPMid.getInstance().audioCardInfo.put("CertNum", cardInfoArray[4]);
	}

	@Override
	public void onClick(View v) {
//		// index:0-"我的首页"，1-"生活服务"，2-"金融服务"，3-"投资理财"
//		Bundle inBundle = new Bundle();
		switch (v.getId()) {
		case R.id.backtitle:
			this.finish();
			break;
		case R.id.hometitle:
//			LPMid.getInstance().um_.backToHome(this, 0);
			ConfigManager.currentView_.finish();
			BCMHomeView.changeScrollTab(2);
			this.finish();
			break;
		}
	}
	
	@Override
	public void finish() {
		super.finish();
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (event.getAction() == KeyEvent.ACTION_DOWN) {
			if (keyCode == KeyEvent.KEYCODE_BACK) {
				this.finish();
				return true;
			}
		}
		return false;
	}
	/** 清除数据 **/
	void cleanView() {
		tvICCard_ID.setText(getString(R.string.iccardNum));
		tvAccountBalance.setText(getString(R.string.accountbalance));
		tvCard_Balance.setText(getString(R.string.cardbalance));
	}
}
